package Chat;

import gui.ServerInfo;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.io.IOException;
import java.io.ObjectOutputStream;

public class ChatClient {
	public ServerInfo si;
	public ObjectOutputStream oos;

	public ChatClient(ServerInfo s) {
		si = s;
		
		try {
			oos = new ObjectOutputStream(si.chatSocket.getOutputStream());
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	private void sendChat(String s) {
		if(!s.isEmpty() && s != null) {
			//String s1 = si.chatSocket.getLocalAddress().getHostName() + ": " + s + "\n";
			String s1 = si.chatSocket.getLocalAddress().getHostName() + ": " + s + "\n";
			try {
				oos.writeUTF(s);
				oos.flush();
				oos.reset();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}
